from django.db import models


# Create your models here.

class RoleModel(models.Model):
    r_name = models.CharField(max_length=100, verbose_name='角色')

    class Meta:
        db_table = 'ayrole'

    def __str__(self):
        return self.r_name


class UserModel(models.Model):
    head_img = models.ImageField(upload_to="upload/", null=True, blank=True, verbose_name="头像")
    u_name = models.CharField(max_length=100, verbose_name='用户')
    username = models.CharField(max_length=100, verbose_name='账号')
    password = models.CharField(max_length=100, verbose_name='密码')
    phone = models.CharField(max_length=100, verbose_name='手机号')
    role = models.ForeignKey(RoleModel, on_delete=models.CASCADE, verbose_name='角色')
    desc = models.CharField(max_length=200, verbose_name='备注')
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    update_time = models.DateTimeField(auto_now=True, verbose_name='更新时间', null=True, blank=True)
    is_del = models.BooleanField(default=False, verbose_name='是否删除')

    class Meta:
        db_table = 'ayuser'

    def __str__(self):
        return self.username
